// 报价单相关类型

// 报价单明细
export interface QuoteItem {
  itemId: number
  quoteId: number
  productId: number
  productName: string
  unitPrice: number
  quantity: number
  totalPrice: number
  remarks?: string
  createTime: Date
  updateTime: Date
}

// 报价单信息
export interface Quote {
  quoteId: number
  quoteNo: string
  customerId: number
  customerName?: string
  totalAmount: number
  discountAmount: number
  finalAmount: number
  status: number
  statusDesc?: string
  remarks?: string
  salesPerson?: string
  salerId?: number       // 报价人ID
  salerPhone?: string    // 报价人手机号
  validDays?: number     // 报价单有效时长（天）
  createBy?: number
  createTime: Date
  updateBy?: number
  updateTime: Date
  items?: QuoteItem[]
}

// 报价单查询参数
export interface QuoteSearch {
  quoteNo?: string
  customerId?: number
  customerName?: string
  status?: number
  salesPerson?: string
  beginTime?: Date
  endTime?: Date
}

// 创建/编辑报价单请求
export interface QuoteCreateRequest {
  quoteId?: number
  customerId: number
  discountAmount?: number
  status?: number
  remarks?: string
  salesPerson?: string
  salerId?: number       // 报价人ID
  salerPhone?: string    // 报价人手机号
  validDays?: number     // 报价单有效时长（天）
  items?: QuoteItemRequest[]
}

// 报价单明细请求
export interface QuoteItemRequest {
  itemId?: number
  productId: number
  quantity: number
  remarks?: string
}

// 报价单状态枚举
export enum QuoteStatus {
  DRAFT = 1,         // 草稿
  PENDING_REVIEW = 2,  // 待审核
  RECEIVED = 3,        // 已接收
  REJECTED = 4         // 已拒绝
}

// 报价单状态选项
export const quoteStatusOptions = [
  { label: '草稿', value: QuoteStatus.DRAFT, color: 'default' },
  { label: '待审核', value: QuoteStatus.PENDING_REVIEW, color: 'processing' },
  { label: '已接收', value: QuoteStatus.RECEIVED, color: 'success' },
  { label: '已拒绝', value: QuoteStatus.REJECTED, color: 'error' }
]

// 获取状态显示信息
export const getQuoteStatusInfo = (status: number) => {
  const option = quoteStatusOptions.find(item => item.value === status)
  return option || { label: '未知', color: 'default' }
}